package com.orange.common.autoconfig.properties;

import com.baidu.aip.face.AipFace;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Data
@ConfigurationProperties("orange.autoconfig.baidu.aip.face")
@Component
@Slf4j
public class AipFaceProperties {
    private String appId;
    private String apiKey;
    private String secretKey;

    @Bean
    public AipFace aipFace() {
        if(appId==null||apiKey==null||secretKey==null){
            log.info("百度人脸识别配置信息未配置");
           return null;
        }

        AipFace client = new AipFace(appId, apiKey, secretKey);
        // 可选：设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);
        return client;
    }
}
